//
//  XYTitleButton.m
//  OC_weibo
//
//  Created by 李旭阳 on 16/1/7.
//  Copyright © 2016年 apple. All rights reserved.
//

#import "XYTitleButton.h"

#define MARGIN 5

@implementation XYTitleButton

-(void)layoutSubviews{
    [super layoutSubviews];
    
    self.titleLabel.x = 0;
    self.imageView.x = CGRectGetMaxX(self.titleLabel.frame) + MARGIN;
    
    self.width = self.titleLabel.width + self.imageView.width + MARGIN;
    self.centerX = self.superview.width * 0.5;
}

-(void)setTitle:(NSString *)title forState:(UIControlState)state{
    [super setTitle:title forState:state];
    [self sizeToFit];
}

-(void)setImage:(UIImage *)image forState:(UIControlState)state{
    [super setImage:image forState:state];
}

@end
